#! /bin/sh

set -e

echo Generating dataset
test-tprtree-Generator -ds 1000 -sl 100 > mix

echo Creating new TPR-Tree and Querying
test-tprtree-TPRTreeLoad mix tree 10 > res

echo Running exhaustive search
test-tprtree-Exhaustive mix > res2

echo Comparing results
sort -n res > a
sort -n res2 > b

set +e
if diff a b; then
    echo "Same results with exhaustive search. Everything seems fine."
    echo Results: `wc -l a`
    rm -rf a b res res2 tree.*
else
    echo "PROBLEM! We got different results from exhaustive search!"
    exit 1
fi
